package com.example.demo8.util;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private static final long serialVersionUID = -2367792939222040305L;

    private Integer code;
    private String message;
    private Object data;


    public static Result ok() {
        return build(200, "操作成功", "");
    }

    public static Result ok(Object data) {
        return build(200, "操作成功", data);
    }

    public static Result fail(String message) {
        return build(500, message, "");
    }

    public static Result build(Integer code, String message, Object data) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        result.setData(data);
        return result;
    }
}
